unit ModifyMultiText;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, sEdit, sButton, sLabel, ExtCtrls, sPanel;

type
  TFormModifyMultiText = class(TForm)
    sPanel1: TsPanel;
    ButtonOk: TsButton;
    ButtonCancel: TsButton;
    EditURL: TsEdit;
    LabelURL: TsLabel;
    EditName: TsEdit;
    LabelName: TsLabel;
    procedure FormShow(Sender: TObject);
    procedure ButtonOkClick(Sender: TObject);
    procedure ButtonCancelClick(Sender: TObject);
    procedure EditNameKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
    FSelect: AnsiString;
    procedure SetSelect(const Value: AnsiString); inline;
  public
    { Public declarations }
    property Select: AnsiString read FSelect write SetSelect;
  end;

var
  FormModifyMultiText: TFormModifyMultiText;

implementation

{$R *.dfm}

procedure TFormModifyMultiText.SetSelect(const Value: AnsiString);
begin
  FSelect := Value;
  EditName.Text := string(Value);
end;

procedure TFormModifyMultiText.ButtonCancelClick(Sender: TObject);
begin
  FSelect := '';
  EditName.Text := string(FSelect);
  ModalResult := mrCancel;
end;

procedure TFormModifyMultiText.ButtonOkClick(Sender: TObject);
begin
  if (AnsiString(EditName.Text) = FSelect) then begin
    Close;
    Exit;
  end;
  FSelect := AnsiString(EditName.Text);
  ModalResult := mrOk;
  Hide;
end;

procedure TFormModifyMultiText.EditNameKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
   ButtonOkClick(Sender)
  else
   if Key = VK_ESCAPE then
    ButtonCancelClick(Sender);
end;

procedure TFormModifyMultiText.FormShow(Sender: TObject);
begin
  ModalResult := mrCancel;
  EditName.SetFocus;
end;

end.
